#pragma once

#include <nxos.h>
#include <wm/surface.h>
#include <wm/event.h>
#include <wm/window.h>

#define NX_WIN_ID_MAX 256
#define NX_WIN_ID_INVALID NX_WIN_ID_MAX

#define WM_WINDOW_MAX_SIZE 65535

typedef enum
{
    WM_flushSync_SEND = 0, /* window send flush event */
    WM_flushSync_RECVED,   /* wm recv flush event */
    WM_flushSync_DONE,     /* wm do flush done */
} WM_FlushSync;

typedef struct
{
    NX_List node;
    NX_WindowConfig config;
    NX_WindowID id;
    NX_Solt vmo;
    NX_Solt vmo_map;
    NX_Solt event;
    NX_Surface surface[1];
    NX_Color bg;
    WM_FlushSync flushSync;
    NX_U32 flags;
    NX_Solt updateSem;
} WM_WindowType;

typedef enum 
{
    WM_RENDER_UPDATE,
} WM_WindowRenderEventType;

typedef struct
{
    WM_WindowRenderEventType type;
    union
    {
        struct
        {
            NX_Region region;
            NX_WindowID wid;
        } update_event;
    };
} WM_WindowRenderEvent;
